package com.travelsmart.client.apresentacao.widget;

import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.SuggestBox;

public class FormSuggestBox extends FormWidget<String>{

	
	private SuggestBox suggestBox;
	
	public FormSuggestBox(String name, String infoHelp, final String[] localidades, final HandlerValidation<String> handler){
		super(handler);
		MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
		for (int i = 0; i < localidades.length; i++) {
			oracle.add(localidades[i]);	
		}
		suggestBox = new SuggestBox(oracle);
		suggestBox.setTitle(infoHelp);
		suggestBox.getTextBox().setName(name);
		super.panel.add(suggestBox);
		super.initHelp(infoHelp);
		initWidget(panel);
	}
	
	public String getValue(){
		return suggestBox.getValue();
	}
	@Override
	public void setFocus(boolean focused) {
		suggestBox.setFocus(focused);
		
	}
}
